#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <lasxintrin.h>

#define DEBUG 0

#if DEBUG
#define LASX_PRINT(RTYPE, element_num, in0)           \
{                                                     \
    RTYPE _tmp0 = (RTYPE)in0;                         \
    int _i = 0;                                       \
    printf("LASX_PRINT %s :",#in0);                   \
    for(_i = 0; _i < element_num; _i++)               \
        printf("%u,",_tmp0[_i]);                      \
    printf("\n");                                     \
}
#endif

int ins_xvsrari_w(void)
{
	v8u32 v0 = {2,3,4,5,6,7,8,9};

	v8u32 v1 = __lasx_xvsrari_w(v0, 1);

#if DEBUG
	LASX_PRINT(v8u32, 8, v0);
	LASX_PRINT(v8u32, 8, v1);
#endif

	//1,2,2,3,3,4,4,5,
	if(v1[0] == 1 && v1[1] == 2 && v1[2] == 2 
			&& v1[3] == 3 && v1[4] == 3 && v1[5] == 4 && v1[6] == 4 && v1[7] == 5)
		return 0;
	else
		return -1;
}

int main(int argc, char **argv)
{
	int ret = 0;

	ret = ins_xvsrari_w();
	
	if(!ret) {
		printf("LASX-256: ins_xvsrari_w test OK\n");
	}
	else {
		printf("LASX-256: ins_xvsrari_w test FAILD\n");
		goto Exit;
	}

	/* test succeed return 0 */
	return 0;

Exit:
	/* test faild return -1 */
	return -1;
}

